home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / dos / format.c < prev    next >
C/C++ Source or Header  |  1996-09-13  |  2KB  |  98 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: format.c,v 1.2 1996/09/13 17:50:07 digulla Exp $
  4.     $Log: format.c,v $
  5.     Revision 1.2  1996/09/13 17:50:07  digulla
  6.     Use IPTR
  7.  
  8.     Revision 1.1  1996/09/11 12:54:45  digulla
  9.     A couple of new DOS functions from M. Fleischer
  10.  
  11.     Desc:
  12.     Lang: english
  13. */
  14. #include <clib/exec_protos.h>
  15. #include <dos/dosextens.h>
  16. #include <dos/filesystem.h>
  17. #include "dos_intern.h"
  18.  
  19. /*****************************************************************************
  20.  
  21.     NAME */
  22.     #include <clib/dos_protos.h>
  23.  
  24.     __AROS_LH3(BOOL, Format,
  25.  
  26. /*  SYNOPSIS */
  27.     __AROS_LHA(STRPTR, devicename, D1),
  28.     __AROS_LHA(STRPTR, volumename, D2),
  29.     __AROS_LHA(ULONG,  dostype,    D3),
  30.  
  31. /*  LOCATION */
  32.     struct DosLibrary *, DOSBase, 119, Dos)
  33.  
  34. /*  FUNCTION
  35.  
  36.     INPUTS
  37.  
  38.     RESULT
  39.  
  40.     NOTES
  41.  
  42.     EXAMPLE
  43.  
  44.     BUGS
  45.  
  46.     SEE ALSO
  47.  
  48.     INTERNALS
  49.  
  50.     HISTORY
  51.     29-10-95    digulla automatically created from
  52.                 dos_lib.fd and clib/dos_protos.h
  53.  
  54. *****************************************************************************/
  55. {
  56.     __AROS_FUNC_INIT
  57.     __AROS_BASE_EXT_DECL(struct DosLibrary *,DOSBase)
  58.  
  59.     /* Get pointer to process structure */
  60.     struct Process *me=(struct Process *)FindTask(NULL);
  61.     struct DosList *dl;
  62.     BOOL success=0;
  63.  
  64.     dl=LockDosList(LDF_DEVICES|LDF_READ);
  65.     dl=FindDosEntry(dl,devicename,LDF_DEVICES);
  66.     if(dl!=NULL)
  67.     {
  68.  
  69.     /* Get pointer to I/O request. Use stackspace for now. */
  70.     struct IOFileSys io,*iofs=&io;
  71.  
  72.     /* Prepare I/O request. */
  73.     iofs->IOFS.io_Message.mn_Node.ln_Type=NT_REPLYMSG;
  74.     iofs->IOFS.io_Message.mn_ReplyPort   =&me->pr_MsgPort;
  75.     iofs->IOFS.io_Message.mn_Length      =sizeof(struct IOFileSys);
  76.     iofs->IOFS.io_Device =dl->dol_Device;
  77.     iofs->IOFS.io_Unit   =dl->dol_Unit;
  78.     iofs->IOFS.io_Command=FSA_FORMAT;
  79.     iofs->IOFS.io_Flags  =0;
  80.     iofs->io_Args[0]=(IPTR)volumename;
  81.     iofs->io_Args[1]=dostype;
  82.  
  83.     /* Send the request. */
  84.     DoIO(&iofs->IOFS);
  85.  
  86.     /* Set error code */
  87.     if(!iofs->io_DosError)
  88.         success=1;
  89.     else
  90.         me->pr_Result2=iofs->io_DosError;
  91.     }else
  92.     me->pr_Result2=ERROR_DEVICE_NOT_MOUNTED;
  93.     /* All Done. */
  94.     UnLockDosList(LDF_DEVICES|LDF_READ);
  95.     return success;
  96.     __AROS_FUNC_EXIT
  97. } /* Format */
  98.